#pragma once

#define WIN32_LEAN_AND_MEAN
#define DIRECTINPUT_VERSION 0x0800
#include <windows.h>
#include <dinput.h>

#include <string>
#include <vector>
#include "DiolObjectInstance.h"

namespace Diol
{

class Device;

/*
	Object
	
	The Object class is the base class for all DirectInput objects that can 
	be found on  a device, like buttons, axes, etc...

	Various information about the object (like its name, etc...) can be found
	in the ObjectIstance associated with the Object.
*/
class Object
{
public:
	virtual void			updateFrom( const DIDEVICEOBJECTDATA& entry ) = 0;
	virtual std::string		toString() const = 0;

	const ObjectInstance&	getObjectInstance() const	{ return mObjectInstance; }
	Device*					getParentDevice() const		{ return mParentDevice; }

	bool					setUserData( UINT_PTR data );
	
protected:
	friend class Device;
	Object( const ObjectInstance& objectInstance, Device* parentDevice );
	virtual ~Object();

	static Object*			createObject( const ObjectInstance& objectInstance, Device* parentDevice );
	
	// Notify the parent device that this object has changed
	void					notifyChanged();

private:
	ObjectInstance			mObjectInstance;
	Device*					mParentDevice;
};

typedef std::vector<Object*> Objects;

}